***Table 1
tabstat fenvmis did lnsize lev tobinq top1 board roa lnage soe, stats (n mean sd min max) c(s)

***Table 2 
reghdfe fenvmis did, a(i.id i.year i.ind i.city) 
reghdfe fenvmis did lnsize lev tobinq top1 board roa lnage soe, a(i.id i.year i.ind i.city) 

***Figure 1 & Table 3 Columns(1)-(2)
gen policy = year - policyt
tab policy
replace policy = -3 if policy < -3
replace policy = 2  if policy > 2
forvalues i = 3(-1)1{
	gen pre_`i' = (policy == -`i' & treat == 1) 
}
gen current = (policy == 0 & treat == 1)
forvalues j = 1(1)2{
	gen  postp_`j' = (policy == `j' & treat == 1)
}
drop pre_3
reghdfe fenvmis pre_* current postp_* lnsize lev tobinq top1 board roa lnage soe , a(i.id i.year i.ind i.city) 

coefplot, levels(90) ///
    keep(pre_* current postp_*) ///
    vertical ///
    yline(0, lcolor(navy) lpattern(solid)) ///
    xline(3, lwidth(thin) lpattern(dash) lcolor(red)) ///
    ylabel(, labsize(*0.75)) ///
    xlabel(1 "-2" 2 "-1" 3 "0" 4 "1" 5 "2", labsize(*0.75)) ///
    xtitle("Years relative to the establishment of environmental courts", size(small) margin(0 0 5 0)) ///
    ytitle("Estimated coefficient", size(small)) ///
    addplot(line @b @at, lcolor(green) lwidth(medium)) ///
    ciopts(lpattern(dash) recast(rcap) lcolor(navy)) ///
    msymbol(circle_hollow) ///
    note("Notes: Vertical bands represent +(-)1.645 times the standard error of each point estimate", size(*0.8))

reghdfe fenvmis pre_* lnsize lev tobinq top1 board roa lnage soe , a(i.id i.year i.ind i.city)

***Table 3 Columns(3)-(4) & Table 4
psmatch2 did lnsize lev tobinq top1 board roa lnage soe , outcome(fenvmis) neighbor(1) caliper(0.001) quietly
pstest lnsize lev tobinq top1 board roa lnage soe , both graph
reghdfe fenvmis did if _support==1, a(i.id i.year i.ind i.city) 
reghdfe fenvmis did lnsize lev tobinq top1 board roa lnage soe if _support==1, a(i.id i.year i.ind i.city) 

***Figure 2
permute did beta = _b[did] se = _se[did] df = e(df_r), ///
	reps(500) seed(123) saving("placebo.dta"): ///
	reghdfe fenvmis did lnsize lev tobinq top1 board roa lnage soe , a(i.id i.year i.ind i.city) 

use "placebo.dta", clear
gen t_value = beta / se
gen p_value = 2 * ttail(df, abs(beta/se))

#delimit ;
twoway (scatter p_value beta)(kdensity beta, yaxis(2)), 
	xline(-0.0825, lc(black*0.5) lp(dash))
	xline(0, lc(black*0.5) lp(solid)) 
	yline(0.1, lc(black*0.5) lp(dash))
	xlabel(-0.2(0.1)0.2)
	xtitle("Estimator", size(*0.8)) xlabel(, format(%4.3f) labsize(small))
	ytitle("Density", size(*0.8)) ylabel(, nogrid format(%4.3f) labsize(small)) 
	ytitle("P Value", size(*0.8) axis(2)) ylabel(, nogrid format(%4.1f) labsize(small) axis(2))
	legend(r(1) order(1 "P Value" 2 "Estimator"))
	graphregion(color(white)) ;
#delimit cr

***Table 3 Columns(5)
zinb fenvmis did lnsize lev tobinq top1 board roa lnage soe i.year, inflate(lnsize soe roa)  

***Table 5 Columns(1)-(2)
reghdfe fenvmis did lnsize lev tobinq top1 board roa lnage soe if scale == 1, a(i.id i.year i.ind i.city)
reghdfe fenvmis did lnsize lev tobinq top1 board roa lnage soe if scale == 0, a(i.id i.year i.ind i.city) 

***Table 5 Columns(3)-(4)
reghdfe fenvmis did lnsize lev tobinq top1 board roa lnage soe if highpoll == 1, a(i.id i.year i.ind i.city)
reghdfe fenvmis did lnsize lev tobinq top1 board roa lnage soe if highpoll == 0, a(i.id i.year i.ind i.city) 

***Table 6
preserve
keep reva revf goala goalf did envexp fispre secgdp lnso2 lngdppc year city
drop if missing(reva, revf, goala, goalf, did, envexp, fispre, secgdp, lnso2, lngdppc, year, city)
duplicates drop
tabstat reva revf goala goalf envexp fispre secgdp lngdppc lnso2, stats (n mean sd min max) c(s)

reghdfe reva did envexp fispre secgdp lngdppc lnso2, a(i.year i.city)  
reghdfe revf did envexp fispre secgdp lngdppc lnso2, a(i.year i.city)  
reghdfe goala did envexp fispre secgdp lngdppc lnso2, a(i.year i.city)  
reghdfe goalf did envexp fispre secgdp lngdppc lnso2, a(i.year i.city)  

restore

***Table 7
reghdfe fgpatent did lnsize lev tobinq top1 board roa lnage soe , a(i.id i.year i.ind i.city) 
reghdfe fdl did lnsize lev tobinq top1 board roa lnage soe , a(i.id i.year i.ind i.city) 
reghdfe flh did lnsize lev tobinq top1 board roa lnage soe , a(i.id i.year i.ind i.city) 
reghdfe ffm did lnsize lev tobinq top1 board roa lnage soe , a(i.id i.year i.ind i.city) 
reghdfe fsy did lnsize lev tobinq top1 board roa lnage soe , a(i.id i.year i.ind i.city) 
reghdfe fdf did lnsize lev tobinq top1 board roa lnage soe , a(i.id i.year i.ind i.city) 
reghdfe fds did lnsize lev tobinq top1 board roa lnage soe , a(i.id i.year i.ind i.city) 
reghdfe flf did lnsize lev tobinq top1 board roa lnage soe , a(i.id i.year i.ind i.city) 
reghdfe fls did lnsize lev tobinq top1 board roa lnage soe , a(i.id i.year i.ind i.city) 

tabstat scale highpoll fgpatent fdf fds flf fls fdl flh ffm fsy, stats (n mean sd min max) c(s)
